package siac.com.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import siac.com.configuracao.ConexaoHibernate;
import siac.com.entity.OrgDepartamento;

public class OrgDepartamentoDao extends AbstractHibernateDao<OrgDepartamento> {
	
	public OrgDepartamentoDao() {
		super(OrgDepartamento.class);
	}

	@Override
	protected Session getSession() {
		return ConexaoHibernate.getSessionFactory().getCurrentSession();
	}

	public List<OrgDepartamento> findCode(Object code) {
		Query query = this.getSession()
				.getNamedQuery("OrgDepartamento.findByCode");
		query.setParameter("code", code);
		return (List<OrgDepartamento>) query.list();
	}

	public List<OrgDepartamento> findName(Object name) {
		Query query = this.getSession()
				.getNamedQuery("OrgDepartamento.findByCode");
		query.setParameter("name", name);
		return (List<OrgDepartamento>) query.list();
	}

	public List<OrgDepartamento> findStatus(Object status) {
		Query query = this.getSession()
				.getNamedQuery("OrgDepartamento.findByStatus");
		query.setParameter("status", status);
		return (List<OrgDepartamento>) query.list();
	}

	public List<OrgDepartamento> findByDireccao(Object direccao) {
		Query query = this.getSession()
				.getNamedQuery("OrgDepartamento.findByDireccao");
		query.setParameter("direccao", direccao);
		return (List<OrgDepartamento>) query.list();
	}
}
